package com.hnevc.kaoshi.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.hnevc.kaoshi.R;

public class MyAdapter extends BaseAdapter {
    Context context;
    String[] timu;
    String[] content;
    String[] price;
    int[] headImg;
    int[] jiaImg;
    int[] jianImg;

    public MyAdapter(Context context, String[] timu, String[] content, String[] price, int[] headImg, int[] jiaImg, int[] jianImg) {
        this.context = context;
        this.timu = timu;
        this.content = content;
        this.price = price;
        this.headImg = headImg;
        this.jiaImg = jiaImg;
        this.jianImg = jianImg;
    }

    @Override
    public int getCount() {
        return timu.length;
    }

    @Override
    public Object getItem(int position) {
        return timu[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null){
            convertView = View.inflate(context, R.layout.listview_item_layout,null);
            TextView timuTv = convertView.findViewById(R.id.title1);
            TextView contentTv = convertView.findViewById(R.id.content1);
            TextView priceTv = convertView.findViewById(R.id.jiage);
            ImageView Img1 = convertView.findViewById(R.id.head_img);
            ImageView Img2 = convertView.findViewById(R.id.jiahao);
            ImageView Img3 = convertView.findViewById(R.id.jianhao);
            timuTv.setText(timu[position]+"");
            contentTv.setText(content[position]+"");
            priceTv.setText(price[position]+"");
            Img1.setImageResource(headImg[position]);
            Img2.setImageResource(jiaImg[position]);
            Img3.setImageResource(jianImg[position]);
        }
        return convertView;
    }
}
